<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="channelsCategory" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{channelsCategoryHome.managed ? 'Edit' : 'Add'} Channels category</f:facet>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                       required="true"
                       disabled="#{channelsCategoryHome.managed}"
                          value="#{channelsCategoryHome.instance.id.id}">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="epgposField" template="layout/edit.xhtml">
                <ui:define name="label">Epgpos</ui:define>
                <h:inputText id="epgpos"
                       disabled="#{channelsCategoryHome.managed}"
                      required="true"
                          size="4"
                     maxlength="4"
                         value="#{channelsCategoryHome.instance.id.epgpos}">
                    <a:support event="onblur" reRender="epgposField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{channelsCategoryHome.persist}"
                       disabled="#{!channelsCategoryHome.wired}"
                       rendered="#{!channelsCategoryHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{channelsCategoryHome.update}"
                       rendered="#{channelsCategoryHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{channelsCategoryHome.remove}"
                      immediate="true"
                       rendered="#{channelsCategoryHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/ChannelsCategory.xhtml"
                rendered="#{channelsCategoryHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty channelsCategoryFrom ? 'ChannelsCategoryList' : channelsCategoryFrom}.xhtml"
                rendered="#{!channelsCategoryHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Category *" labelClass="required">
    <div class="association" id="categoryParent">

        <h:outputText value="There is no category associated with this channelsCategory."
                   rendered="#{channelsCategoryHome.instance.category == null}"/>

        <rich:dataTable var="_category"
                   value="#{channelsCategoryHome.instance.category}"
                rendered="#{channelsCategoryHome.instance.category != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="categoryTable">
            <h:column>
                <f:facet name="header">Category id</f:facet>
                <h:outputText value="#{_category.categoryId}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Category</f:facet>
                <h:outputText value="#{_category.category}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{channelsCategoryHome.instance.category != null ? 'changeParent' : 'selectParent'}" value="#{channelsCategoryHome.instance.category != null ? 'Change' : 'Select'} category"
                       view="/CategoryList.xhtml">
                <f:param name="from" value="ChannelsCategoryEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Channels *" labelClass="required">
    <div class="association" id="channelsParent">

        <h:outputText value="There is no channels associated with this channelsCategory."
                   rendered="#{channelsCategoryHome.instance.channels == null}"/>

        <rich:dataTable var="_channels"
                   value="#{channelsCategoryHome.instance.channels}"
                rendered="#{channelsCategoryHome.instance.channels != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="channelsTable">
            <h:column>
                <f:facet name="header">Epg pos</f:facet>
                <h:outputText value="#{_channels.epgPos}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{_channels.name}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Image</f:facet>
                <h:outputText value="#{_channels.image}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Favourite</f:facet>
                <h:outputText value="#{_channels.favourite}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Channel sigla</f:facet>
                <h:outputText value="#{_channels.channelSigla}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{channelsCategoryHome.instance.channels != null ? 'changeParent' : 'selectParent'}" value="#{channelsCategoryHome.instance.channels != null ? 'Change' : 'Select'} channels"
                       view="/ChannelsList.xhtml">
                <f:param name="from" value="ChannelsCategoryEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
